
//
//  Student.m
//  PostMessa
//
//  Created by never down on 15-5-20.
//  Copyright (c) 2015年 ygy_ios. All rights reserved.
//

#import "Student.h"
//static Student * singletonStu;

@implementation Student

+(Student *)getSingletonStudent{
    static Student * singletonStu;
    NSLog(@"%lu",sizeof(singletonStu));
    @synchronized(self){
        if(singletonStu == nil){
            singletonStu = [[[self class] alloc]init];
            return singletonStu;
        }else{
            return singletonStu;
        }
    }
}

+(void)getSynTest{
    static dispatch_once_t onceToken;
    void (^executeOnlyOnce)(void) = ^(void)
    {
        static NSUInteger numOfEntries = 0;
        numOfEntries++;
        NSLog(@"Executed %lu times in  %@",(unsigned long)numOfEntries,[NSThread currentThread]);
    };
    
    dispatch_once(&onceToken, ^(void)
    {
//        dispatch_sync(, )
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), executeOnlyOnce);
    });
    
    dispatch_once(&onceToken, ^(void)
    {
//        dispatch_sync(, )
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), executeOnlyOnce);
    });
    
    static dispatch_once_t testToken;
    dispatch_once(&testToken, ^(void)
    {
        NSLog(@"####:Current thread = %@", [NSThread currentThread]);
    });
}

@end
